﻿<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}
</head>

<body>
<style>
    .account span{display: block;line-height:20px;font-size:12px;border-radius:8px;color:#fff;}
    .account span:nth-child(1){background-color: #f0ad4e;margin-bottom:5px}
    .account span:nth-child(2){background-color: #5bc0de;}
    .layui-table-body .layui-table-cell {height:90px; line-height: 90px;}
</style>
<div class="newtest">
    <div class="container new_serach">
        {volist name="powerList" id="vo"}
        <a class="btn btn-primary btn-sm" href="{$vo['url']}">{$vo.name}</a>
        {/volist}
    </div>
    <div class="container new_serach">

        <span> 身份证号：</span>
        <div class="layui-inline">
            <input class="form-control serach_key" name="idCard" value="{$idCard}" type="text">
        </div>

        <span> 手机号：</span>
        <div class="layui-inline">
            <input class="form-control serach_key" name="mobile" value="{$mobile}" type="text">
        </div>

        <span> 姓名：</span>
        <div class="layui-inline">
            <input class="form-control serach_key" name="realName" value="{$realName}" type="text">
        </div>

        <span> 注册时间：</span>
        <div class="layui-inline">
            <input type="text" class="layui-input" id="test6" name="time" value="{$time}" placeholder=" - ">
        </div>
        <button class="layui-btn layui-btn-sm" data-type="reload">搜索</button>

    </div>

    <div class="new_main">

        <table class="layui-hide" id="demo" lay-filter="demo"></table>
        <script type="text/html" id="barDemo">
            <a class="btn-sm btn-primary" lay-event="js-modal" >账户变动</a>
            <a class="btn-sm btn-primary" lay-event="card">查看银行卡</a>
            <a class="btn-sm btn-primary" lay-event="detail">查看详情</a>
        </script>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
<!--                <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="getCheckLength">批量删除</button>-->
            </div>
        </script>


    </div>
</div>




</body>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<script>
    var modal = new yii.modal();
    layui.use(['form','jquery','layer','laydate','table'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格
        //日期范围
        laydate.render({
            elem: '#test6'
            , range: true
        });

        //搜索操作
        $('.layui-btn').click(function () {
            var time = $('input[name="time"]').val();
            var idCard = $('input[name="idCard"]').val();
            var mobile = $('input[name="mobile"]').val();
            var realName = $('input[name="realName"]').val();
            table.reload('demo', {
                url:"{:URL('admin/citizens/index')}"
                , request: {
                    pageName: 'page' //页码的参数名称，默认：page
                    , limitName: 'pageSize' //每页数据量的参数名，默认：limit
                }
                , where: {
                    time: time,
                    idCard: idCard,
                    mobile:mobile,
                    realName:realName
                }
                , page: {
                    curr: 1
                }
            });
        });

        table.render({
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports', 'print'],
            elem: '#demo', // 表格id
            url:"{:URL('admin/citizens/index')}",
            where:{type:'list'},
            title: '市民数据表',
            page: true, // 树形表格一般是没有分页的
            cols: [
                [
                {field: 'id', title: 'ID',  sort: true, fixed: 'left',rowspan:2}
                ,{title: '微信基本信息',colspan:2,align:'center'}
                ,{title: '实名信息',colspan:5,align:'center'}
                ,{title: '账户', align:'center', colspan:2}
                ,{field: 'addtime', title: '注册时间',sort: true,rowspan:2,width:180,align: 'center'}
                ,{fixed: 'right',title: '操作', width:360, align:'center', toolbar: '#barDemo',rowspan:2}
            ],
            [
                {title: '头像',field:'avatar',width:80,align: 'center'},
                {title: '昵称',field:'nickname',width:200,align: 'center'},
                {field: 'realName', title: '真实姓名',rowspan:2,width:180,align: 'center'},
                {field: 'sexVal', title: '性别',rowspan:2,align: 'center'}
                ,{field: 'mobile', title: '手机号',rowspan:2,width:120,align: 'center'}
                ,{field: 'idCard', title: '身份证号',rowspan:2,width:180,align: 'center'},
                {title: '余额',field:'integral',width:80,align: 'center'},
                {title: '积分',field:'balance',width:80,align: 'center'},
            ]
            ],
            done: function() {
                layer.closeAll('loading');
            }
        });

        //监听行工具事件
        table.on('tool(demo)', function(obj){
            var id = obj.data.id;
            switch(obj.event){
                case 'js-modal':
                    modal.initialization({
                        url: "{:URL('common/Common/topupView')}",
                        type: "post",
                        data:{
                            id:id
                        }
                    });
                    break;
                case 'card':
                    //银行卡列表
                    modal.initialization({
                        url: "{:URL('common/Common/cardView')}",
                        type: "post",
                        data:{
                            id:id
                        }
                    });
                    break;
                case 'detail':
                        modal.initialization({
                            url: "{:URL('admin/citizens/detail')}",
                            type: "post",
                            data:{
                                id:id
                            }
                        });
                        break;
            };
        });

        //账户变动实际操作
        modal.on("updateAddress",function(){
            let id = $(modal.getid()).find('input[name=id]').val();
            let type = $(modal.getid()).find('#changes .active').attr("id")
            let status = $(modal.getid()).find('input[name='+type+'_status]:checked').val();
            let number = $(modal.getid()).find('input[name='+type+'_number]').val();
            let remark = $(modal.getid()).find('textarea[name='+type+'_remark]').val();
            if(number==''){
                layer.alert("请输入变动数目");
                return;
            }
            let data = {id:id,type:type,status:status,number:number,remark:remark};
            $.ajax({
                type: "post",
                url: "{:URL('admin/citizens/changes')}",
                data: data,
                dataType: "json",
                success: function(data){
                    layer.alert(data.msg);
                    if(data.code==0){
                        //执行重载
                        table.reload('demo');
                        $(modal.getid()).find(".btn-default").click();
                    }
                }
            });
        });


    });


</script>

</html>
